Skip to content

Add server-only MSBUILDDEBUGONSTART modes - #14988

Merged
JanProvaznik merged 1 commit into
dotnet:mainfrom
JanProvaznik:server-only-debug-on-start
Sep 9, 2026
Merged

JanProvaznik merged 1 commit into
dotnet:mainfrom
JanProvaznik:server-only-debug-on-start

Conversation

@JanProvaznik

Copy link
Copy Markdown
Member

Context

MSBUILDDEBUGONSTART stops the forwarding client and can pause a new server long enough to trigger connection-timeout fallback. Debugging should target the process performing the build instead.

Changes Made

Add server-only modes: 4 launches a debugger; 5 prints the server PID and waits for attachment. Both use the existing hook after connection and before evaluation, including on reused servers. Production change: 11 lines, plus focused tests and documentation.

Compatibility

Values 1-3, connection timeouts, cancellation, fallback, APIs, and protocols are unchanged. These modes do not enable Server or cover early startup/handshake debugging; abandoning a wait requires manually resuming or stopping the server.

Testing

Four focused ServerOnlyDebugging* cases passed on both .NET 11 and .NET Framework 4.7.2: in-process skipping and cold/warm server waits. Manual server debugging also confirmed locally. Non-Windows execution was not exercised.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 54b82003-8c38-401d-bf86-b87943e67ae2
Copilot AI lite review requested due to automatic review settings September 9, 2026 13:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The changes are opt-in, correctly gated to server nodes, and include focused tests plus documentation updates aligning with the stated compatibility goals.

Pull request overview

This PR refines MSBUILDDEBUGONSTART for MSBuild Server debugging by adding server-only modes that avoid pausing the forwarding client (which can otherwise trigger connection-timeout fallback) and instead pause/launch the debugger in the server process at a safe point (after client connection, before evaluation), including for reused servers.

Changes:

  • Add MSBUILDDEBUGONSTART=4 (server-only debugger launch) and =5 (server-only “print PID + wait for attach”) to XMake.DebuggerLaunchCheck.
  • Add targeted unit tests validating that modes 4/5 don’t affect in-proc builds and that mode 5 blocks before evaluation for cold and warm servers.
  • Document the new modes and recommended usage patterns in the wiki pages.
File summaries
File Description
src/MSBuild/XMake.cs Adds server-only debug modes 4 (launch) and 5 (wait-for-attach) gated on s_isServerNode.
src/MSBuild.UnitTests/MSBuildServer_Tests.cs Adds focused tests for server-only debug modes, including warm-server reuse coverage.
documentation/wiki/MSBuild-Environment-Variables.md Documents modes 4/5 behavior, scope, and operational caveats.
documentation/wiki/Building-Testing-and-Debugging-on-.Net-Core-MSBuild.md Adds a dedicated “Debugging MSBuild Server” section with example usage.
Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@JanProvaznik
JanProvaznik merged commit b9cf941 into dotnet:main Sep 9, 2026
20 of 21 checks passed
This was referenced Nov 15, 2026

This branch was previously deployed

1 inactive deployment
copilot-pat-pool — f1b5c107 Deployed Sep 9, 2026 by JanProvaznik via conclusion #837
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants